package io02;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class Io2Test {
    public static void main(String[] args) throws IOException {
        //1. 缓冲流实现文件的复制------CopyDemo3Buffered
/*       FileInputStream fis = new FileInputStream("111.jpg");
       BufferedInputStream bis = new BufferedInputStream(fis);
        FileOutputStream fos = new FileOutputStream("wkj_cp2.jpg");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        long start = System.currentTimeMillis();
        int d;
        while((d=bis.read())!=-1){ //使用缓冲流读取字节
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕!耗时:"+(end-start)+"ms");
       bis.close(); */

        //3. 转换流读写字符---------------OSWDemo+ISRDemo
/*        FileOutputStream fos = new FileOutputStream("osw.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("和我在成都的街头走一走，哦哦哦哦...");
        osw.write("直到所有的灯都熄灭了也不停留");
        System.out.println("写出完毕!");
        osw.close(); */

/*        FileInputStream fis = new FileInputStream("osw.txt");
        InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
        int d;
        while((d=isr.read())!=-1){
            System.out.print((char)d);
        }
        isr.close();*/

        //2. 对象流读写对象---------------Student+OOSDemo+OISDemo
/*        private String name;
        private int age;
        private String gender;
        private transient String[] otherInfo;

    public Student() {
        }

    public Student(String name, int age, String gender, String[] otherInfo) {
            this.name = name;
            this.age = age;
            this.gender = gender;
            this.otherInfo = otherInfo;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public String getGender() {
            return gender;
        }

        public void setGender(String gender) {
            this.gender = gender;
        }

        public String[] getOtherInfo() {
            return otherInfo;
        }

        public void setOtherInfo(String[] otherInfo) {
            this.otherInfo = otherInfo;
        }

        @Override
        public String toString() {
            return "Student{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    ", gender='" + gender + '\'' +
                    ", otherInfo=" + Arrays.toString(otherInfo) +
                    '}';
        }*/

/*        String name = "张三";
        int age = 25;
        String gender = "男";
        String[] otherInfo = {"是一名学生","黑龙江佳木斯的","喜欢打篮球","喜欢王老师"};
        Student zs = new Student(name,age,gender,otherInfo);
        System.out.println(zs);
        FileOutputStream fos = new FileOutputStream("student.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(zs);
        System.out.println("写出完毕");
        oos.close();*/

/*        FileInputStream fis = new FileInputStream("student.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Object obj = ois.readObject();
        Student zs = (Student)obj;
        System.out.println(zs);
        ois.close();*/
    }

}
